package com.tedu.bill.demo7;

import com.tedu.bill.demo7.Teacher;

/**
 * Author：毕龙
 * Date: 2024/5/7 19:13
 */
public class School {
    public void assign(int n){
        if(n % 2 == 0){
            //Class 'Anonymous class derived from Teacher' must either
            // be declared abstract or implement abstract method 'teacher()' in 'Teacher'
          /*  Teacher t1 = new Teacher(){
                @Override
                public void teach(String course) {
                    System.out.println("教"+course+"课程");
                }
            };
            t1.teach("java");
            */
            /*
            * lambda表达式是一个接口的引用->
            * */
            Teacher t1 = (course) -> {
                System.out.println("教"+course+"课程");
            };
            t1.teach("java");
        }else{
        /*    new Teacher(){

                @Override
                public void teach(String course) {
                    System.out.println("教"+course+"课程");
                }
            }.teach("oracle");*/
            Teacher t1 = (course) -> {
                System.out.println("教"+course+"课程");
            };
            t1.teach("oracle");
        }
    }
}
